001 /* 002 * Copyright 2005 Stephen J. McConnell 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 013 * implied. 014 * 015 * See the License for the specific language governing permissions and 016 * limitations under the License. 017 */ 018 019 package net.dpml.tools.impl; 020 021 import net.dpml.library.Resource; 022 023 import net.dpml.tools.Context; 024 025 import org.apache.tools.ant.BuildListener; 026 import org.apache.tools.ant.BuildEvent; 027 import org.apache.tools.ant.Project; 028 029 /** 030 * Standard build listener. 031 * 032 * @author <a href="http://www.dpml.net">The Digital Product Meta Library</a> 033 * @version 1.0.0 034 */ 035 public class StandardBuildListener implements BuildListener 036 { 037 private final Context m_context; 038 039 /** 040 * Creation of a new standard build listener. 041 * @param context the wotrking context 042 */ 043 public StandardBuildListener( Context context ) 044 { 045 if( null == context ) 046 { 047 throw new NullPointerException( "context" ); 048 } 049 050 m_context = context; 051 } 052 053 /** 054 * Signals that a build has started. This event 055 * is fired before any targets have started. 056 * 057 * @param event An event with any relevant extra information. 058 * Must not be <code>null</code>. 059 */ 060 public void buildStarted( BuildEvent event ) 061 { 062 Resource resource = m_context.getResource(); 063 String path = resource.getResourcePath(); 064 String version = resource.getVersion(); 065 Project project = m_context.getProject(); 066 project.log( "\n-------------------------------------------------------------------------" ); 067 project.log( path + "#" + version ); 068 project.log( "-------------------------------------------------------------------------" ); 069 } 070 071 /** 072 * Signals that the last target has finished. This event 073 * will still be fired if an error occurred during the build. 074 * 075 * @param event An event with any relevant extra information. 076 * Must not be <code>null</code>. 077 * 078 * @see BuildEvent#getException() 079 */ 080 public void buildFinished( BuildEvent event ) 081 { 082 } 083 084 /** 085 * Signals that a target is starting. 086 * 087 * @param event An event with any relevant extra information. 088 * Must not be <code>null</code>. 089 * 090 * @see BuildEvent#getTarget() 091 */ 092 public void targetStarted( BuildEvent event ) 093 { 094 } 095 096 /** 097 * Signals that a target has finished. This event will 098 * still be fired if an error occurred during the build. 099 * 100 * @param event An event with any relevant extra information. 101 * Must not be <code>null</code>. 102 * 103 * @see BuildEvent#getException() 104 */ 105 public void targetFinished( BuildEvent event ) 106 { 107 } 108 109 /** 110 * Signals that a task is starting. 111 * 112 * @param event An event with any relevant extra information. 113 * Must not be <code>null</code>. 114 * 115 * @see BuildEvent#getTask() 116 */ 117 public void taskStarted( BuildEvent event ) 118 { 119 } 120 121 /** 122 * Signals that a task has finished. This event will still 123 * be fired if an error occurred during the build. 124 * 125 * @param event An event with any relevant extra information. 126 * Must not be <code>null</code>. 127 * 128 * @see BuildEvent#getException() 129 */ 130 public void taskFinished( BuildEvent event ) 131 { 132 } 133 134 /** 135 * Signals a message logging event. 136 * 137 * @param event An event with any relevant extra information. 138 * Must not be <code>null</code>. 139 * 140 * @see BuildEvent#getMessage() 141 * @see BuildEvent#getPriority() 142 */ 143 public void messageLogged( BuildEvent event ) 144 { 145 } 146 }